﻿<%@ WebHandler Language="C#" Class="TryApsLimitedCapacityHandler" %>
//Description:有限产能排产--预排
//Copyright (c) : 通力凯顿（北京）系统集成有限公司
//Writer:Wangjh
//create Date:2023-03-20
using System;
using System.Web;
using BusinessRule.DTO;
using BusinessRule.Business;
using BusinessRule.IBusiness;
using BusinessRule.BusinessFactory;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Web.SessionState;
using System.Data;
using System.IO;
using DatabaseAccess.DBUtility;

public class TryApsLimitedCapacityHandler : IHttpHandler, IRequiresSessionState
{
    private TryLimitedCapacityBusiness m_LMObj = new TryLimitedCapacityBusiness();
    InfiniteCapacityBusiness m_InfiniteObj = new InfiniteCapacityBusiness();
    private uLMSCommonIBusiness m_CommonObj = uMESBusinessFactory.instance.GetuLMSCommonObject();
    CurrentUserInfo m_UserInfo;

    public void ProcessRequest(HttpContext context)
    {
        try
        {
            var action = context.Request["action"].ToString();
            m_UserInfo = (CurrentUserInfo)context.Session["CurrentUserInfo"];
            switch (action)
            {
                case "searchData":
                    SearchData(context);
                    break;
                case "getContainerLMAps":
                    GetContainerLMAps(context);
                    break;
                case "apsLmCalculate":
                    ApsLmCalculate(context);//有限产能排产计算
                    break;
                case "getStepLimitedAps"://有限产能工序级计划查看,甘特图
                    GetStepLimitedAps(context);
                    break;
                case "getStepLimitedAps2"://有限产能工序级计划查看,列表
                    GetStepLimitedAps2(context);
                    break;
                case "apsLmCalculateChange":
                    ApsLmCalculateChange(context);
                    break;
                case "apsLmCalculateExport"://排产结果导出
                    ExportApsLmCalculate(context);
                    break;
                ///*-----------无限排产相关--------------*/
                //case "ApsLNCalculate"://无限排产计算
                //    ApsLNCalculate(context);
                //    break;
                default:
                    break;
            }
        }
        catch (Exception e)
        {
            var result = new uMESProcessResult()
            {
                Result = false,
                Message = e.Message
            };
            context.Response.Write(JsonConvert.SerializeObject(result));
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

    /// <summary>
    /// 导出排产数据
    /// </summary>
    /// <param name="context"></param>
    public void ExportApsLmCalculate(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        uMESProcessResult result = new uMESProcessResult();
        result.Result = false;

        DataTable conDt = new DataTable();
        if (!string.IsNullOrWhiteSpace(context.Request["containers"].ToString()))
        {
            conDt = JsonConvert.DeserializeObject<DataTable>(context.Request["containers"].ToString());
        }
        else
        {
            result.Message = "无效参数";
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;
        }
        var apsplandetailids = string.Empty;
        if (!string.IsNullOrWhiteSpace(context.Request["ids"].ToString()))
        {
            apsplandetailids = context.Request["ids"].ToString();
        }

        DataTable dt = m_LMObj.GetContainerLMApsExport(conDt, apsplandetailids);

        dt.Columns["apsplandetailid"].ColumnName = "apsplandetailid(勿改)";
        dt.Columns["apstypename"].ColumnName = "策略(勿改)";
        dt.Columns["realcontainerno"].ColumnName = "批次号(勿改)";
        dt.Columns["productname"].ColumnName = "件号(勿改)";
        dt.Columns["workflowname"].ColumnName = "工艺规程(勿改)";
        dt.Columns["workflowrevision"].ColumnName = "工艺版本(勿改)";
        dt.Columns["workflowstepname"].ColumnName = "工序(勿改)";
        dt.Columns["workcentername"].ColumnName = "工区(勿改)";
        dt.Columns["teamname"].ColumnName = "班组(勿改)";
        dt.Columns["resourcedesc"].ColumnName = "设备名称(勿改)";
        dt.Columns["resourcename"].ColumnName = "设备编码";
        dt.Columns["apsempname"].ColumnName = "人员(勿改)";
        dt.Columns["starttime"].ColumnName = "计划开始时间";
        dt.Columns["endtime"].ColumnName = "计划结束时间";

        var ms = uLMS_CommonFunction.DataTableExportToExcel(dt, "预排-排产结果");


        var Response = HttpContext.Current.Response;
        Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}{1}.xls", HttpContext.Current.Server.UrlEncode("排产结果"), DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss")));
        Response.AddHeader("fileDownload", "1");
        Response.AddHeader("Set-Cookie", "fileDownload=true;path=/");
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
        Response.ContentType = "application/ms-excel;charset=UTF-8";
        Response.BinaryWrite(ms);

        Response.Flush();
        Response.End();
        Response.Close();

        context.Response.Write(JsonConvert.SerializeObject(Response));
    }

    /// <summary>
    /// 有限产能排产
    /// </summary>
    /// <param name="context"></param>
    public void ApsLmCalculateChange(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        uMESProcessResult result = new uMESProcessResult();
        result.Result = false;

        Dictionary<string, string> para = new Dictionary<string, string>();
        para["EmployeeID"] = m_UserInfo.EmployeeID.ToString();
        para["ApsType"] = context.Request["apstype"].ToString();
        para["StartTime"] = context.Request["startTime"].ToString();
        para["EndTime"] = context.Request["endTime"].ToString();
        para["WorkcenterID"] = context.Request["workcenterId"].ToString();
        para["TeamID"] = context.Request["TeamId"].ToString();
        para["EmployeeIds"] = context.Request["employeeIds"].ToString();
        para["ResourceID"] = context.Request["resourceId"].ToString();
        para["ApsplanDetailID"] = context.Request["apsplanDetailId"].ToString();
        para["Sequence"] = context.Request["sequence"].ToString();
        DataTable conDt = new DataTable();
        if (!string.IsNullOrWhiteSpace(context.Request.Form["containers"].ToString()))
        {
            conDt = JsonConvert.DeserializeObject<DataTable>(context.Request.Form["containers"].ToString());
        }
        else
        {
            result.Message = "无效参数";
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        result = m_LMObj.LMAPSChange(conDt, para);

        if (!result.Result)
        {
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        result.Result = true;
        context.Response.Write(JsonConvert.SerializeObject(result));
    }

    /// <summary>
    /// 获取工序的排产计划,列表展示用
    /// </summary>
    /// <param name="context"></param>
    public void GetStepLimitedAps2(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        uMESProcessResult result = new uMESProcessResult();
        result.Result = false;

        Dictionary<string, string> para = new Dictionary<string, string>();
        if (context.Request["apsPlanInfoID"] != null && !string.IsNullOrWhiteSpace(context.Request["apsPlanInfoID"].ToString()))
        {
            para.Add("ApsPlanInfoID", context.Request["apsPlanInfoID"].ToString());
        }

        if (context.Request["workflowStepId"] != null && !string.IsNullOrWhiteSpace(context.Request["workflowStepId"].ToString()))
        {
            para.Add("WorkflowStepID", context.Request["workflowStepId"].ToString());
        }

        if (para.Keys.Count == 0)
        {
            result.Message = "参数无效";
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        DataTable dt = m_LMObj.GetStepLMAps2(para);

        if (dt.Rows.Count == 0)
        {
            result.Message = "无数据";
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        result.DBTable = dt;
        result.Result = true;
        context.Response.Write(JsonConvert.SerializeObject(result));
    }

    /// <summary>
    /// 获取工序的排产计划,甘特图用
    /// </summary>
    /// <param name="context"></param>
    public void GetStepLimitedAps(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        uMESProcessResult result = new uMESProcessResult();
        result.Result = false;

        Dictionary<string, string> para = new Dictionary<string, string>();
        para.Add("ApsPlanInfoIDs", "");
        if (!string.IsNullOrWhiteSpace(context.Request["param"].ToString()))
        {
            DataTable param = JsonConvert.DeserializeObject<DataTable>(context.Request["param"].ToString());
            if (param.Rows.Count > 0)
            {
                foreach (DataRow r in param.Rows)
                {
                    string _ApsPlanInfoIDs = r["apsPlanInfoIDs"].ToString();
                    foreach (string id in _ApsPlanInfoIDs.Split(','))
                    {
                        if (string.IsNullOrWhiteSpace(id))
                        {
                            continue;
                        }
                        para["ApsPlanInfoIDs"] += "'" + id + "',";
                    }

                }
            }
        }
        para["ApsPlanInfoIDs"] = para["ApsPlanInfoIDs"].TrimEnd(',');

        if (para.Keys.Count == 0)
        {
            result.Message = "参数无效";
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        DataTable dt = m_LMObj.GetStepLMAps(para);

        if (dt.Rows.Count == 0)
        {
            result.Message = "无数据";
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        Dictionary<string, object> apsData = new Dictionary<string, object>();
        List<Dictionary<string, object>> returnData = new List<Dictionary<string, object>>();

        DataTable conDt = dt.DefaultView.ToTable(true, "containerid", "workflowid");//批次 

        foreach (DataRow con in conDt.Rows)
        {
            var conStepApsInfo = dt.Select("containerid='" + con["containerid"].ToString() + "' and workflowid='" + con["workflowid"].ToString() + "'").CopyToDataTable();
            var conApsInfo = conStepApsInfo.DefaultView.ToTable(true, "apsplaninfoid", "constarttime", "conendtime", "containername", "ApsType", "containerid", "workflowid");//批次级计划
            var conApsRow = conApsInfo.Rows[0];

            apsData = new Dictionary<string, object>();
            apsData["id"] = conApsRow["containerid"].ToString();
            apsData["name"] = conApsRow["containername"].ToString();

            List<Dictionary<string, object>> conperiods = new List<Dictionary<string, object>>();
            Dictionary<string, object> conPeriod = new Dictionary<string, object>();
            Dictionary<string, object> customData = new Dictionary<string, object>();
            //批次级计划，可能3种方案
            foreach (DataRow _conApsRow in conApsInfo.Rows)
            {
                conPeriod = new Dictionary<string, object>();
                var apsType = ""; var fillColor = "";
                switch (_conApsRow["ApsType"].ToString())
                {
                    case "1":
                        apsType = "正排";
                        fillColor = "#64b5f6";
                        break;
                    case "2":
                        apsType = "倒排";
                        fillColor = "#009688";
                        break;
                    case "3":
                        apsType = "瓶颈排";
                        fillColor = "#9d8a0e";
                        break;
                    default:
                        break;
                }
                conPeriod["id"] = _conApsRow["apsplaninfoid"].ToString();
                conPeriod["text"] = _conApsRow["containername"].ToString() + "(" + apsType + ")";
                conPeriod["start"] = _conApsRow["constarttime"].ToString();
                conPeriod["end"] = _conApsRow["conendtime"].ToString();
                conPeriod["fill"] = fillColor;

                //个性化属性
                customData = new Dictionary<string, object>();
                customData["apsType"] = _conApsRow["ApsType"].ToString();

                conPeriod["customData"] = customData;

                conperiods.Add(conPeriod);
            }
            apsData["periods"] = conperiods;

            //批次级个性化属性
            customData = new Dictionary<string, object>();
            customData["containerid"] = con["containerid"].ToString();
            customData["workflowid"] = con["workflowid"].ToString();

            apsData["customData"] = customData;

            returnData.Add(apsData);

            //工序级信息
            DataTable conStep = conStepApsInfo.DefaultView.ToTable(true, "containerid", "workflowid", "workflowstepid", "workflowstepname");//工序信息                      

            foreach (DataRow step in conStep.Rows)
            {
                Dictionary<string, object> stepApsData = new Dictionary<string, object>();

                stepApsData["id"] = step["workflowstepid"].ToString();
                stepApsData["name"] = step["workflowstepname"].ToString();
                List<Dictionary<string, object>> periods = new List<Dictionary<string, object>>();
                Dictionary<string, object> period = new Dictionary<string, object>();

                //此批次和此工序的所有排产计划
                DataTable _conStepApsInfo = conStepApsInfo.Select("containerid='" + con["containerid"].ToString() + "' and workflowstepid='" + step["workflowstepid"].ToString() + "'").CopyToDataTable();
                foreach (DataRow stepAps in _conStepApsInfo.Rows)
                {
                    period = new Dictionary<string, object>();
                    var apsType = ""; var fillColor = "";
                    switch (stepAps["ApsType"].ToString())
                    {
                        case "1":
                            apsType = "正排";
                            fillColor = "#64b5f6";
                            break;
                        case "2":
                            apsType = "倒排";
                            fillColor = "#009688";
                            break;
                        case "3":
                            apsType = "瓶颈排";
                            fillColor = "#9d8a0e";
                            break;
                        default:
                            break;
                    }
                    period["id"] = stepAps["apsplandetailid"].ToString();
                    period["text"] = stepAps["workflowstepname"].ToString() + "(" + apsType + ")";
                    period["start"] = stepAps["stepstarttime"].ToString();
                    period["end"] = stepAps["stependtime"].ToString();
                    period["fill"] = fillColor;
                    //个性化属性
                    customData = new Dictionary<string, object>();
                    customData["apsType"] = stepAps["ApsType"].ToString();

                    period["customData"] = customData;

                    periods.Add(period);
                }



                //测试，添加假期
                //if (stepAps["workflowstepname"].ToString() == "50-工序50")
                //{
                //    period = new Dictionary<string, object>();
                //    period["id"] = Guid.NewGuid().ToString();
                //    period["text"] = "假期";
                //    period["start"] = "2022/4/30 0:00:00";
                //    period["end"] = "2022/5/4 0:00:00";
                //    period["customData"] = new Dictionary<string, string>() { { "isHolidate", "1" } };
                //    periods.Add(period);
                //}                

                stepApsData["periods"] = periods;
                stepApsData["parent"] = conApsRow["containerid"].ToString();

                returnData.Add(stepApsData);
            }

        }

        result.ReturnData = JsonConvert.SerializeObject(returnData);
        //result.DBTable = dt;
        result.Result = true;
        context.Response.Write(JsonConvert.SerializeObject(result));
    }

    /// <summary>
    /// 无限产能排产
    /// </summary>
    /// <param name="context"></param>
    public void ApsLNCalculate(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        uMESProcessResult result = new uMESProcessResult();
        result.Result = true;

        string apsType = context.Request["apstype"].ToString();
        if (apsType == "3")//无限，瓶颈排
        {
            result.Result = false;
            result.Message = "无限排产暂无瓶颈排";
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;
        }
        Dictionary<string, string> para = new Dictionary<string, string>();
        para["EmployeeID"] = m_UserInfo.EmployeeID.ToString();

        //取本分厂的日历
        DataTable dtFcMc = DatabaseHelper.Query_ReturnDatTable(string.Format("SELECT f.makecalendarid FROM factory f WHERE f.factoryid = '{0}'", m_UserInfo.FactoryID));
        para["MakeCalendarID"] = dtFcMc.Rows.Count == 0 ? "" : dtFcMc.Rows[0]["makecalendarid"].ToString();

        DataTable conDt = new DataTable();
        if (!string.IsNullOrWhiteSpace(context.Request.Form["containers"].ToString()))
        {
            conDt = JsonConvert.DeserializeObject<DataTable>(context.Request.Form["containers"].ToString());
        }
        else
        {
            result.Result = false;
            result.Message = "无效参数";
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        //yuxj20230224增加是否为整个排产池标记
        if (context.Request["isWholePool"] != null && conDt.Columns.Contains("apspoolid"))
        {
            string WholePoolId = "";
            if (context.Request["isWholePool"].ToString() == "1")
            {
                //重新根据poolid查询需要处理的数据 
                WholePoolId = conDt.Rows[0]["apspoolid"].ToString();
                conDt = m_LMObj.GetApsPoolContainerInfo(new Dictionary<string, string>() { { "PoolID", WholePoolId } }).DBTable;
            }
        }

        DataTable faConDt = new DataTable();
        if (conDt.Select("ISSUBCON is null").Length > 0)
        {
            faConDt = conDt.Select("ISSUBCON is null").CopyToDataTable();//主卡            
        }
        DataTable sonConDt = new DataTable();
        if (conDt.Select("ISSUBCON='1'").Length > 0)
        {
            sonConDt = conDt.Select("ISSUBCON='1'").CopyToDataTable();//子卡
        }

        //排产主卡
        if (apsType == "1")//无限，正排
        {
            m_InfiniteObj.LnPositiveCalculate(faConDt, para);
        }
        else if (apsType == "2")//无限，倒排
        {
            m_InfiniteObj.LnReverseCalculate(faConDt, para);
        }

        //排产子卡
        if (result.Result && sonConDt.Rows.Count > 0)
        {
            if (apsType == "1")//无限，正排
            {
                m_InfiniteObj.LnPositiveCalculate(sonConDt, para);
            }
            else if (apsType == "2")//无限，倒排
            {
                m_InfiniteObj.LnPositiveCalculate(sonConDt, para);
            }
        }

        //重置参数，刷新数据
        para.Clear();
        para["EmployeeID"] = m_UserInfo.EmployeeID.ToString();
        DataTable dt = m_InfiniteObj.GetContainerInfiniteAps(conDt);//刷新排产数据

        result.DBTable = dt;
        context.Response.Write(JsonConvert.SerializeObject(result));
    }

    /// <summary>
    /// 有限产能排产
    /// </summary>
    /// <param name="context"></param>
    public void ApsLmCalculate(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        uMESProcessResult result = new uMESProcessResult();
        result.Result = false;

        string apsType = context.Request["apstype"].ToString();
        Dictionary<string, string> para = new Dictionary<string, string>();
        para["EmployeeID"] = m_UserInfo.EmployeeID.ToString();

        DataTable conDt = new DataTable();
        if (!string.IsNullOrWhiteSpace(context.Request.Form["containers"].ToString()))
        {
            conDt = JsonConvert.DeserializeObject<DataTable>(context.Request.Form["containers"].ToString());
        }
        else
        {
            result.Message = "无效参数";
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        //yuxj20230224增加是否为整个排产池标记
        if (context.Request["isWholePool"] != null && conDt.Columns.Contains("apspoolid"))
        {
            string WholePoolId = "";
            if (context.Request["isWholePool"].ToString() == "1")
            {
                //重新根据poolid查询需要处理的数据 
                WholePoolId = conDt.Rows[0]["apspoolid"].ToString();
                conDt = m_LMObj.GetApsPoolContainerInfo(new Dictionary<string, string>() { { "PoolID", WholePoolId } }).DBTable;
            }
        }

        DataTable faConDt = new DataTable();
        if (conDt.Select("ISSUBCON is null").Length > 0)
        {
            faConDt = conDt.Select("ISSUBCON is null").CopyToDataTable();//主卡            
        }
        DataTable sonConDt = new DataTable();
        if (conDt.Select("ISSUBCON='1'").Length > 0)
        {
            sonConDt = conDt.Select("ISSUBCON='1'").CopyToDataTable();//子卡
        }

        //排产主卡
        if (apsType == "1")//有限，正排
        {
            result = m_LMObj.LMPositiveCalculate(faConDt, para);
        }
        else if (apsType == "2")//有限，倒排
        {
            result = m_LMObj.LMReverseCalculate(faConDt, para);
        }
        else if (apsType == "3")//有限，瓶颈排
        {
            result = m_LMObj.LMBottleneckCalculate(faConDt, para);
        }
        //排产子卡
        if (result.Result && sonConDt.Rows.Count > 0)
        {
            //sonConDt = m_LMObj.GetSonContainerStartEndDate(sonConDt, apsType);
            //if (sonConDt.Select("STARTTIME is null").Length > 0)
            //{
            //    result.Result = false;
            //    result.Message = "未找到主卡的子工序的排产信息";
            //}
            //else
            //{
            if (apsType == "1")//有限，正排
            {
                result = m_LMObj.LMPositiveCalculate(sonConDt, para);
            }
            else if (apsType == "2")//有限，倒排
            {
                result = m_LMObj.LMReverseCalculate(sonConDt, para);
            }
            else if (apsType == "3")//有限，瓶颈排
            {
                result = m_LMObj.LMBottleneckCalculate(sonConDt, para);
            }
            //}

        }

        if (!result.Result)
        {
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;
        }

        //重置参数，刷新数据
        para.Clear();
        para["EmployeeID"] = m_UserInfo.EmployeeID.ToString();
        DataTable dt = m_LMObj.GetContainerLMAps(conDt, para);//刷新排产数据

        result.Result = true;
        result.DBTable = dt;
        context.Response.Write(JsonConvert.SerializeObject(result));
    }


    /// <summary>
    /// 有限产能批次级数据查询
    /// </summary>
    /// <param name="context"></param>
    public void GetContainerLMAps(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        uMESProcessResult result = new uMESProcessResult();
        result.Result = false;

        Dictionary<string, string> para = new Dictionary<string, string>();
        para["EmployeeID"] = m_UserInfo.EmployeeID.ToString();

        DataTable conDt = new DataTable();
        if (!string.IsNullOrWhiteSpace(context.Request.Form["containers"].ToString()))
        {
            conDt = JsonConvert.DeserializeObject<DataTable>(context.Request.Form["containers"].ToString());
        }
        else
        {
            result.Message = "无效参数";
            context.Response.Write(JsonConvert.SerializeObject(result));
            return;
        }
        if (context.Request["apsType"] != null && !string.IsNullOrWhiteSpace(context.Request["apsType"].ToString()))
        {
            para["ApsType"] = context.Request["apsType"].ToString();
        }

        DataTable dt = m_LMObj.GetContainerLMAps(conDt, para);
        result.DBTable = dt;
        result.Result = true;
        context.Response.Write(JsonConvert.SerializeObject(result));
    }

    //设置字典列表
    private Dictionary<string, string> SetPara(HttpContext context)
    {
        Dictionary<string, string> para = new Dictionary<string, string>();

        para.Add("CurrentPageIndex", context.Request.Form["pageNumber"].ToString());//页码
        para.Add("PageSize", context.Request.Form["pageSize"].ToString());//每页页数

        if (!string.IsNullOrWhiteSpace(context.Request.Form["containerName"].ToString()))
        {
            para.Add("ContainerName", context.Request.Form["containerName"].ToString());
        }

        if (!string.IsNullOrWhiteSpace(context.Request.Form["productName"].ToString()))
        {
            para.Add("ProductName", context.Request.Form["productName"].ToString());
        }

        if (!string.IsNullOrWhiteSpace(context.Request.Form["mfgorderName"].ToString()))
        {
            para.Add("MfgorderName", context.Request.Form["mfgorderName"].ToString());
        }
        //
        if (!string.IsNullOrWhiteSpace(context.Request.Form["factoryId"].ToString()))
        {
            para.Add("FactoryID", context.Request.Form["factoryId"].ToString());
        }

        if (!string.IsNullOrWhiteSpace(context.Request.Form["poolId"].ToString()))//排产池
        {
            para.Add("PoolID", context.Request.Form["poolId"].ToString());
        }
        if (!string.IsNullOrWhiteSpace(context.Request.Form["orderBStartDate"].ToString()))
        {
            para.Add("OrderBStartDate", context.Request.Form["orderBStartDate"].ToString());
        }

        if (!string.IsNullOrWhiteSpace(context.Request.Form["orderEStartDate"].ToString()))
        {
            para.Add("OrderEStartDate", context.Request.Form["orderEStartDate"].ToString());
        }

        if (!string.IsNullOrWhiteSpace(context.Request.Form["orderBEndDate"].ToString()))
        {
            para.Add("OrderBEndDate", context.Request.Form["orderBEndDate"].ToString());
        }

        if (!string.IsNullOrWhiteSpace(context.Request.Form["orderEEndDate"].ToString()))
        {
            para.Add("OrderEEndDate", context.Request.Form["orderEEndDate"].ToString());
        }

        if (!string.IsNullOrWhiteSpace(context.Request.Form["realBStartDate2"].ToString()))
        {
            para.Add("RealBStartDate2", context.Request.Form["realBStartDate2"].ToString());
        }
        if (!string.IsNullOrWhiteSpace(context.Request.Form["realEStartDate2"].ToString()))
        {
            para.Add("RealEStartDate2", context.Request.Form["realEStartDate2"].ToString());
        }

        if (!string.IsNullOrWhiteSpace(context.Request.Form["workflowStepName"].ToString()))
        {
            para.Add("WorkflowStepName", context.Request.Form["workflowStepName"].ToString());
        }

        if (m_UserInfo != null)
        {
            para.Add("EmployeeID", m_UserInfo.EmployeeID.ToString());
        }

        if (!string.IsNullOrWhiteSpace(context.Request.Form["workcenterid"].ToString()))
        {
            para.Add("workcenterid", context.Request.Form["workcenterid"].ToString());
        }

        if (!string.IsNullOrWhiteSpace(context.Request.Form["teamid"].ToString()))
        {
            para.Add("teamid", context.Request.Form["teamid"].ToString());
        }

        return para;
    }

    /// <summary>
    /// 查询获取列表
    /// </summary>
    /// <param name="context"></param>
    public void SearchData(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        uMESProcessResult result = new uMESProcessResult();
        result.Result = false;

        Dictionary<string, string> para = SetPara(context);

        result = m_LMObj.GetApsPoolContainerInfo(para, true);
        context.Response.Write(JsonConvert.SerializeObject(result));
    }

}